package Date_Calendar;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

public class Example5 {
    public static void main(String[] args) {
    //在Java8 之后，提供了 LocalTime, LocalDate , LocalDateTime 类
        //1、通过LocalDateTime的now()方法可以创建该实例
        LocalDateTime localDateTime = LocalDateTime.now();
        System.out.println("当前时间：" + localDateTime);
        System.out.println("The Year = " + localDateTime.getYear());
        System.out.println("The Month = " + localDateTime.getMonth());
        System.out.println("The Day = " + localDateTime.getDayOfMonth());
        System.out.println("The Hour = " + localDateTime.getHour());
        System.out.println("The Minute = " + localDateTime.getMinute());
        System.out.println("The Second = " + localDateTime.getSecond());
        System.out.println("======================");

        //2、若只考虑获取年月日(日期)信息，可以考虑使用LocalDate类 now()方法
        LocalDate localDate = LocalDate.now();
        System.out.println(localDate);

        //3、若只考虑获取时分秒(时间)信息，可以考虑使用LocalTime类 now()方法
        LocalTime localTime = LocalTime.now();
        System.out.println(localTime);
    }
}
